Skip to content

Convert Dolby Vision profile 7 to 8.1 on devices without a profile 7 decoder - #2017

Merged
damontecres merged 6 commits into
damontecres:mainfrom
SergeiAK:dv7-conversion
Oct 28, 2026
Merged

damontecres merged 6 commits into
damontecres:mainfrom
SergeiAK:dv7-conversion

Conversation

@SergeiAK

Copy link
Copy Markdown
Contributor

Description

On Amlogic boxes (S905X4 and similar) Dolby Vision Profile 7 does not play as Dolby Vision.
The server transcodes it, or, with "Direct play Dolby Vision Profile 7" switched on by hand, the
decoder answers NoSupport and fallback ends in HDR10. Devices with a native Profile 7 decoder,
such as the Shield, are not affected and nothing changes for them.

This PR converts Profile 7 to 8.1 on the fly. It has two halves and one decision:

  1. util/DolbyVisionProfile7Filter.kt — an entry in the BitstreamFilter list from Add option to prefer Dolby Vision over HDR10+ on hybrid videos #1876. It
    drops the enhancement layer (NAL 63) and has libdovi rewrite the RPU to 8.1. The decoder gets
    either a fully converted access unit or an untouched one: with no RPU, an RPU that is not
    Profile 7, a libdovi refusal, or a result that does not fit the buffer, the bytes stay as they
    were. If the native library fails to load, the filter switches itself off for good with a
    single log line. Counts of converted / passed through / refused access units are logged on
    release().
  2. util/DolbyVisionProfile7ExtractorsFactory.kt — rewrites only Format.codecs of a
    dvhe.07.xx / dvh1.07.xx video track to …08.xx. Without it nothing works: media3 picks the
    decoder by this string, and with dvhe.07 every Dolby Vision decoder on Amlogic answers
    NoSupport. Samples are not touched. DRM tracks are not rewritten, since their samples bypass
    the filter. It wraps withAssMkvSupport from the outside, so libass's Matroska replacement is
    covered too.
  3. util/DolbyVisionProfile7Conversion.isWanted() — one condition for all of it: experimental
    settings are on, and the preference is on, and the device does not list a Profile 7
    decoder, and it does list a Profile 8 one (new supportsHevcDolbyVisionProfile8() in
    MediaCodecCapabilitiesTest). The same condition enables direct play of DOVIWithEL in
    DeviceProfileService, so the manual toggle is not needed.

The preference convertDolbyVisionProfile7 is proto field 6 in the experimental settings, off by
default. In WholphinRenderersFactory the filter comes first in the list, followed by the HDR10+
masking from #1876.

Dependency: com.suyashbelekar:exoplayerhdrutils:0.4.1 — MIT, on Maven Central, with the
native library for arm64-v8a / armeabi-v7a / x86_64, exactly the ABIs this app splits on.
Only LibDovi is used. The library's HevcFrameTransformer is not: it decides from the first
frame and throws on a frame without an RPU. The library pulls in media3 1.10.1 transitively;
Gradle resolves it to the project's 1.11.1.

On taking the library as a whole (#1540): as already noted in #244, the published releases
of the library do not rewrite the codec string, which on Amlogic is a silent failure — the
conversion reports success and the display stays in HDR10. The fix lives in an unmerged branch
of the library. This PR does not depend on it.

What this PR does not do. The enhancement layer is dropped; that is the price of the
conversion, which is why devices with a native Profile 7 decoder are left alone.
BlockAdditional (an enhancement layer outside the stream) is not read — like the rest of
Wholphin today — so such a file stays HDR10, as it is now.

Related issues

Closes #244

Builds on #1876 (the BitstreamFilter list). Related to #1540. @fanni42 asked for exactly this on
an S905X4 in #1876.

Testing

Hardware — a debug build of this branch, Homatics box (Amlogic S905X4, Android 14) + LG BX,
Jellyfin 12.1.0, a Profile 7 FEL remux with the enhancement layer in band, played from the start
for 39 seconds. Only the new preference was switched on; manual "Direct play Dolby Vision
Profile 7" was off:

Server decision DirectPlay
Codec string dvhe.07.06 → dvhe.08.06
Decoder c2.amlogic.dolby-vision.dvhe.decoder; dav1 and dvav answer NoSupport; no Format exceeds…
Display onHdrInfoChange=3 0.4 s after the decoder was created; hdmi_hdr_status SDR → DolbyVision-Std → SDR after exit; Dolby Vision badge on the TV
Filter 948 access units converted, 0 passed through, 0 refused

The same measurement on the branch before the rebase (library 0.3.0, 16 September) gave the
same result with 1200 access units over 45 seconds.

Unit tests — 25, on the JVM without the native part:

  • DolbyVisionProfile7FilterTest (14) — a fake rewriter on a direct buffer: offset ≠ 0,
    position/limit untouched, every "bytes stay as they were" branch, three-byte start codes,
    UnsatisfiedLinkError tried once;
  • DolbyVisionProfile7ExtractorsFactoryTest (5, mockk) — only the video track is rewritten;
  • DolbyVisionProfile7ConversionTest (6) — codec strings, DRM, dvh1.

CI in my fork ran on this branch plus a debug signing commit: pre-commit,
testDefaultDebugUnitTest and assembleDefaultDebug are all green. The hardware measurement
above is that build.

Screenshots

The only UI change is one toggle in the experimental settings.

AI or LLM usage

The code was written with Claude (Claude Code): the filter, the extractor wrapper, the condition
and the tests. I reviewed every line and can explain it. It was tested with the unit tests and
the hardware measurement above. This description was written by me in Russian and translated
into English with the same assistant.

@fanni42

fanni42 commented Sep 30, 2026

Copy link
Copy Markdown

I tested it with a Homatics Box R 4K plus, it worked fine for me.
I only have one observation, that there was a Dolby Vision HDR hybrid that was not good anyway,
but I managed to solve this by deleting the code below, which is found twice in the code:
if (jellyfinTenEleven) add("DOVIInvalid")

So all hybrid movies played fine after deleting the above.
Interestingly, my jellyfin server is 12.1, so it seems that the bool value is not working.

@SergeiAK

Copy link
Copy Markdown
Contributor Author

Thanks for testing on the Homatics — good to have it confirmed on a second S905X4 box.

The hybrid file is a separate thing from Profile 7, and the flag is working as intended:
jellyfinTenEleven means "server is 10.11 or newer", so on 12.1 it is true. That is exactly
why DOVIInvalid ends up on the unsupported list. Since 10.11 the server tags a whole class of
Dolby Vision files DOVIInvalid — typically Profile 8 with compatibility ID 6 (Blu-ray rips
converted from Profile 7) or 0 — and a client that doesn't list that range type as supported
gets them transcoded. Removing the line makes Wholphin accept them, which is why your file
played.

I'd rather not fold that into this PR: the Jellyfin team declined to change the classification
(jellyfin/jellyfin#18097) and warned that
out-of-spec DV files can crash some players, while explicitly leaving it to clients to advertise
DOVIInvalid if they choose to. So it should be an opt-in setting rather than a removed line.
I've opened #2021 for that — your result is a useful data point there.

@SergeiAK

Copy link
Copy Markdown
Contributor Author

A short status, in case it helps with review. Since the PR was opened it has been run by two
other people on their own boxes: @fanni42 on a Homatics Box R 4K Plus (worked fine), and
@Demo23019 on a Wholphin build with this code in #1540, who reports Profile 7 now converts and
plays as Dolby Vision. I measured it myself on Amlogic S905X4 and Nvidia Shield.

It is behind an experimental toggle, off by default, so it changes nothing for anyone who does not
enable it. I'll rebase onto the current main before you get to it.

Profile 7 is HDR10 compatible HEVC plus an RPU in NAL unit type 62 and an
enhancement layer in type 63. A decoder which lists profile 8 but not
profile 7 takes such a stream but does not switch the display into Dolby
Vision for it, so the picture comes out as the HDR10 base layer. Kodi,
Vimu and Dune play these files in Dolby Vision on the same hardware by
rewriting the RPU into its profile 8.1 form and dropping the enhancement
layer; nothing is re-encoded.

DolbyVisionProfile7Filter does that as an entry in the BitstreamFilter
list: every access unit is copied without its type 63 units into a direct
scratch buffer, libdovi (ExoplayerHdrUtils, MIT, already on Maven Central)
rewrites the RPU there, and the result is copied back only once it has
succeeded and fits, so a refused access unit reaches the decoder untouched.
Access units without an RPU, or whose RPU is not profile 7, pass through.

media3 chooses the decoder by Format.codecs, and a decoder without profile
7 answers "not supported" to dvhe.07; with decoder fallback on, playback
then lands on whichever decoder is first in the list. So
DolbyVisionProfile7ExtractorsFactory advertises profile 7 video tracks as
dvhe.08 at the extractor, which also sets MediaFormat.KEY_PROFILE right.

Both halves, and direct play of profile 7 in the device profile, are
switched on by one decision: the experimental preference is on, the
device lists no profile 7 decoder, and it does list a profile 8 one. A
device which decodes profile 7 itself keeps the enhancement layer the
conversion would throw away.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@SergeiAK

SergeiAK commented Oct 14, 2026 •

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #1644 (now at b0c318d).

#1644 removed the dolbyVisionELDirectPlay parameter this PR used to allow direct play
of profile 7, so the hook moved to the new mechanism: when the conversion is active
(experimental toggle on, no profile 7 decoder, a profile 8 one present), the profile 7
range types from HdrFormat.DOVI_PROFILE_7 are added to forceEnabledHdr. A user who
sets the new "Dolby Vision profile 7" override to disabled still wins, since
forceDisabledHdr is applied last. The range types are the same two as before
(DOVIWithEL, DOVIWithELHDR10Plus, Jellyfin 10.11+ only), so behaviour is unchanged.

ktlint is clean and all 422 unit tests pass locally.

Update: re-tested the rebased branch on a Homatics Box R 4K Plus (Amlogic, Android 14) with an LG OLED, built together with #2065 on top of main at 9f55741:

Setting Result
Conversion on, "Dolby Vision profile 7" override on auto Direct play, dvhe.07.06 advertised as dvhe.08.06, c2.amlogic.dolby-vision.dvhe.decoder, Dolby Vision on the TV; 1913 access units converted, 0 passed through, 0 refused
Conversion on, override set to Disabled Transcode with VideoRangeTypeNotSupported, plain HEVC decoder, SDR, so the explicit override wins over the conversion

@damontecres damontecres added the enhancement New feature or request label Oct 26, 2026
@damontecres
damontecres self-requested a review October 26, 2026 18:32
@damontecres damontecres added the playback Related to media playback label Oct 26, 2026

@damontecres damontecres left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks good. I think have a decent grasp on how this works.

I pushed a few minor changes. It doesn't look like exoplayerhdrutils ship consumer proguard rules., so I also pushed a proguard rule to keep the native class.

damontecres added a commit that referenced this pull request Oct 26, 2026
@damontecres
damontecres merged commit 2f7804f into damontecres:main Oct 28, 2026
2 checks passed
@hvownij

hvownij commented Nov 1, 2026

Copy link
Copy Markdown

Tested development build, google 4k streamer. Successful displayed correctly using the new feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request playback Related to media playback

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA] - Dolby Vision Compatibility Mode (Profile 7 to 8.1 Conversion)

4 participants